import 'package:lishopflu/base/controller_import.dart';

import '../../base/view_import.dart';
import 'main_ctl.dart';
import 'main_drawer.dart';
import 'message_page.dart';
import 'shop_car_page.dart';
import 'home_page.dart';
import 'my_page.dart';
import 'story_page.dart';

class MainPage extends BasePage<MainCtl>{

  List<BottomNavigationBarItem> bottomTabs;

  @override
  Widget build(BuildContext context) {
    onCreate(mContext);
    return Scaffold(
      drawer: Drawer(child: MainDrawer(context).homeDrawer(),),
      body: Navigator(
        key: Get.nestedKey(1),
        initialRoute: AppPages.HOME,
        onGenerateRoute: controller.onGenerateRoute,
      ),
      /*body: PageView(
        physics: NeverScrollableScrollPhysics(),
        children: <Widget>[
          HomePage(),
          StoryPage(),
          MessagePage(),
          ShopCarPage(),
          MyPage(),
        ],
        onPageChanged: controller.onPageChanged,
        controller: controller.pageController,
      ),*/
      bottomNavigationBar: Obx(() => BottomNavigationBar(
            items: bottomTabs,
            currentIndex: controller.page.value,
            type: BottomNavigationBarType.fixed,
            onTap: controller.changePage,
          ),
      ),
    );
  }

  @override
  void onCreate(BuildContext mContext) {
    setAppTitle('Main');
    bottomTabs = <BottomNavigationBarItem>[
      _bnItem(Icons.home, '首页'),
      _bnItem(Icons.apps, '逛逛'),
      _bnItem(Icons.message, '消息'),
      _bnItem(Icons.shopping_cart, '购物车'),
      _bnItem(Icons.person, '我的'),
    ];
  }

  @override
  Widget pageBody(BuildContext context) => null;

  _bnItem(IconData icon, String title) =>
      BottomNavigationBarItem(
        icon: Icon(icon),
        label: title,
      );
}